// 上传模块

// 调用方法：
// $.post('http://http://api.juzhen05.com/admin/matrixbox/login'


var path = require('path')
var routerApi = require('../../../utils/routeString.js')(__filename, __dirname);

var jwt = require('../../../utils/jwt.js')
var MartixBox = require('../dal/matrixbox.js')

server.post({ path: routerApi, name: routerApi }, async function (req, res, next) {
    var body = req.body || req.query;

    if (!body.account || !body.password) {
        return res.send({ code: 0, msg: '请输入您的账号和密码' });
    }

    if (body.account === "admin" && body.password === "pw2017") {
        var jwtData = await jwt.encode(body.account);
        return res.send({ code: 1, token: jwtData });
    } else {
        return res.send({ code: 0, msg: '账号密码错误' });
    }
    
});

